package com.res.share.controller;

import com.res.share.common.utils.CategoryUtils;
import com.res.share.common.Constants;
import com.res.share.model.ResCategory;
import com.res.share.service.ResCateGoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Order(value = 1)
public class CategoryApplicationRun implements ApplicationRunner {

    @Autowired
    private ResCateGoryService resCateGoryService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<ResCategory> resCategoryListStart = resCateGoryService.findResCategoryListStart();
        CategoryUtils.setValue(Constants.CATE_BASE_KEY,resCategoryListStart);
    }
}
